package cn.laixueit.base;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author duxiang
 * @date 2023/11/27 11:06
 */

public class BaseController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    public <T> Page<T> page(){
        return getPage();
    }

    private <T> Page<T> getPage() {
        Integer page = Convert.toInt(request.getParameter("page"), 1);
        Integer size = Convert.toInt(request.getParameter("size"), 10);
        return new Page<T>(page,size,true);
    }
}
